package com.fh.fruit.service.classify.impl;

import java.util.List;
import javax.annotation.Resource;
import org.springframework.stereotype.Service;
import com.fh.dao.DaoSupport;
import com.fh.fruit.entity.classify.Classify;
import com.fh.fruit.service.classify.ClassifyManager;
import com.fh.util.PageData;


@Service("classifyService")
public class ClassifyService implements ClassifyManager{

	@Resource(name = "daoSupport")
	private DaoSupport dao;

	@SuppressWarnings("unchecked")
	@Override
	public List<PageData> synTree(int parseInt) throws Exception {
		return (List<PageData>) dao.findForList("ClassifyMapper.synTree", parseInt);
	}

	/**
	 * 通过ID获取其子一级分类
	 * @param parentId
	 * @return
	 * @throws Exception
	 */
	@SuppressWarnings("unchecked")
	public List<Classify> classifyByParentId(int parentId) throws Exception {
		return (List<Classify>) dao.findForList("ClassifyMapper.listAllClassify", parentId);
	}
	
	/**
	 * 通过菜单ID获取数据
	 * @param pd
	 * @return
	 * @throws Exception
	 */
	public PageData getClassifyById(PageData pd) throws Exception {
		return (PageData) dao.findForObject("ClassifyMapper.getClassifyById", pd);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PageData> selectClassifyByParendId(Integer parentId) throws Exception {
		return (List<PageData>) dao.findForList("ClassifyMapper.selectClassifyByParendId", parentId);
	}

	@Override
	public void saveClassify(PageData pd) throws Exception {
		dao.save("ClassifyMapper.saveClassify", pd);
	}

	@Override
	public void updateEdit(PageData pd) throws Exception {
		dao.update("ClassifyMapper.updateEdit", pd);
	}

	@Override
	public int getClassGoods(String id)throws Exception {
		return (int)dao.findForObject("ClassifyMapper.getClassGoods", id);
	}

	@Override
	public void deleteClassifyById(String id) throws Exception {
		dao.delete("ClassifyMapper.deleteClassifyById", id);
	}

	@Override
	public int getClassifyIsP(PageData pd) throws Exception {
		return (int)dao.findForObject("ClassifyMapper.getClassifyIsP", pd);
	}
}
